package com.itheima.day15.TCP.test5;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10006);
        Socket accept = ss.accept();

        InputStream is = accept.getInputStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("backBurner\\a\\源氏头像复制.jpg"));
        int i;
        while((i = bis.read()) != -1){
            bos.write(i);
        }

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bw.write("接收完成");
        bw.newLine();
        bw.flush();

        bos.close();
        accept.close();
        ss.close();

    }
}
